import { SkillInfoPanel } from "../SkillInfoPanel";
import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
import { SkillBaseInfoRender } from "./SkillBaseInfoRender";
import { SkillInfo } from "../../../model/SkillInfo";
import { ESkillUseType } from "../../../../../Message/Public/ESkillUseType";
//class SkillBaseInfoPanel
    
    export  class SkillBaseInfoPanel extends SkillInfoPanel
    {
        constructor()
        {
            super();
            this._gbox = new GBox();
            this._gbox.verticalGap = 10;
            this._gbox.direction = GBoxDirection.VERTICAL;
            this._gbox.x = 5;
            this._gbox.y = 0;
            addChild(this._gbox);
            return;
        }

        public initList(arg1: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            this.dispose();
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1[loc1];
                (loc4 = ObjectPool.getObject(SkillBaseInfoRender)).updateData(loc3);
                this._gbox.addChild(loc4);
                ++loc1;
            }
            this._gbox.invalidate();
            return;
        }

        public addSkill(arg1: SkillInfo): void
        {
            var loc1=null;
            if (arg1.tSkill.useType == ESkillUseType._ESkillUseTypeAuto) 
            {
                loc1 = this.getXPSkill();
                if (loc1) 
                {
                    loc1.updateData(arg1);
                    this._gbox.invalidate();
                    return;
                }
            }
            loc1 = ObjectPool.getObject(SkillBaseInfoRender);
            loc1.updateData(arg1);
            if (arg1.position < this._gbox.numChildren) 
            {
                this._gbox.addChildAt(loc1, arg1.position);
            }
            else 
            {
                this._gbox.addChild(loc1);
            }
            this._gbox.invalidate();
            return;
        }

        public /* override */ updateInfo(arg1: SkillInfo): void
        {
            _skillMapData = arg1;
            _skill = arg1.tSkill;
            return;
        }

        public getXPSkill(): SkillBaseInfoRender
        {
            var loc1=0;
            var loc3=null;
            var loc2=this._gbox.numChildren;
            while (loc1 < loc2) 
            {
                loc3 = this._gbox.getChildAt(loc1) as SkillBaseInfoRender;
                if (loc3.skill.tSkill.useType == ESkillUseType._ESkillUseTypeAuto) 
                {
                    return loc3;
                }
                ++loc1;
            }
            return null;
        }

        public dispose(): void
        {
            var loc1=null;
            while (this._gbox.numChildren > 0) 
            {
                loc1 = this._gbox.removeChildAt(0) as SkillBaseInfoRender;
                ObjectPool.disposeObject(loc1, SkillBaseInfoRender);
            }
            return;
        }

        protected /* var */_gbox: GBox;
    }
